<?php 
/**
 *@扣除积分操作
 */
//引入数据库文件
include "../public/common.php";
// var_dump($_POST);
// exit;
if($_POST['integral'] && $_POST['reason']) {
	$redNum = $_POST['integral'];
	$redDet = $_POST['reason'];
	$card_id = $_POST['id'];
	$tel = $_POST['tel'];
	//增加积分sql语句
	$sql = "insert into red(card_id,redNum,redDet) values({$card_id},{$redNum},'{$redDet}')";
	// echo $sql;
	// exit;
	if($result = $conn->query($sql)) {
		// 更新总积分
		$sql = "update card set card_integral = card_integral-{$redNum} where card_id ={$card_id} ";
		if($result = $conn->query($sql)) {
			echo "<script>location='search.php?tel={$tel}';</script>";
		}
	}else {
		echo "数据插入失败";
	}
}


 ?>